package com.xinyue.game.server.codec;

import io.netty.buffer.ByteBuf;

public class GameMessageHeader {

	public static int HEADER_LENGHT = 26;
	private int messageId;
	private int seqId;
	private int version;
	private long sendTime;
	private boolean compress;
	private boolean encrypt;
	private int errorCode;


	public void write(ByteBuf byteBuf) {
		byteBuf.writeInt(messageId);
		byteBuf.writeInt(seqId);
		byteBuf.writeInt(version);
		byteBuf.writeLong(sendTime);
		byteBuf.writeByte(compress ? 1 : 0);
		byteBuf.writeByte(encrypt ? 1 : 0);
	}

	public void read(ByteBuf byteBuf) {
		this.messageId = byteBuf.readInt();
		this.seqId = byteBuf.readInt();
		this.version = byteBuf.readInt();
		this.sendTime = byteBuf.readLong();
		this.compress = byteBuf.readByte() == 1 ? true : false;
		this.encrypt = byteBuf.readByte() == 1 ? true : false;
	}

	public int getMessageId() {
		return messageId;
	}

	public void setMessageId(int messageId) {
		this.messageId = messageId;
	}

	public int getSeqId() {
		return seqId;
	}

	public void setSeqId(int seqId) {
		this.seqId = seqId;
	}

	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	public long getSendTime() {
		return sendTime;
	}

	public void setSendTime(long sendTime) {
		this.sendTime = sendTime;
	}

	public boolean isCompress() {
		return compress;
	}

	public void setCompress(boolean compress) {
		this.compress = compress;
	}

	public boolean isEncrypt() {
		return encrypt;
	}

	public void setEncrypt(boolean encrypt) {
		this.encrypt = encrypt;
	}

	public int getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(int errorCode) {
		this.errorCode = errorCode;
	}

}
